Skip to content

feat(template): derive ErrorTemplate from proto Template option - #20

Open
yordis wants to merge 3 commits into
mainfrom
yordis/feat-template-from-proto
Open

feat(template): derive ErrorTemplate from proto Template option#20
yordis wants to merge 3 commits into
mainfrom
yordis/feat-template-from-proto

Conversation

@yordis

@yordis yordis commented May 6, 2026

Copy link
Copy Markdown
Member
  • Lets services declare their error contract once in proto and pick it up in Go without hand-rewriting the same domain/reason/code/visibility/help/metadata in two places.
  • Field-level FieldOptions (visibility, value/default_value) drive per-instance metadata, so a populated proto message becomes a fully-formed error without per-call boilerplate.

@cursor

cursor Bot commented May 6, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New public API controls error shape and metadata visibility from proto annotations; misconfiguration could leak or omit fields, though behavior is covered by tests and existing templates are unchanged unless adopters use the new helpers.

Overview
Adds proto-driven error templates so Go ErrorTemplate values can be built from trogon.error.v1alpha1 message and field options instead of duplicating domain, reason, code, visibility, help, and metadata in code.

NewErrorTemplateFromProto reads the message template option once (and caches field specs); FromProto turns a populated proto into a TrogonError, mapping annotated fields to metadata (fixed value, default_value fallbacks, runtime overrides, and caller ErrorOptions winning last). ErrorTemplate.NewError now also applies template-level metadata baked at construction time.

Tooling: buf.gen.yaml, internal test protos + generated Go under internal/testdata/gen, a CI Generated Code Up-To-Date job (buf generate + clean git diff), .gitattributes for generated files, Go 1.26, and a direct dependency on github.com/TrogonStack/trogonproto.

Reviewed by Cursor Bugbot for commit d25ae72. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 60850456-27ef-4d3a-90de-4d7cb3207a26

📥 Commits

Reviewing files that changed from the base of the PR and between 35182a3 and d25ae72.

⛔ Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • internal/testdata/gen/trogonerror/testdata/v1/errors.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • internal/testdata/proto/buf.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .gitattributes
  • .github/workflows/ci.yml
  • buf.gen.yaml
  • error.go
  • example_test.go
  • go.mod
  • internal/testdata/proto/buf.yaml
  • internal/testdata/proto/trogonerror/testdata/v1/errors.proto
  • template_proto.go
  • template_proto_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/feat-template-from-proto

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…mapping

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis force-pushed the yordis/feat-template-from-proto branch from 6191c3f to d25ae72 Compare September 5, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant